from typing import Optional, List
from pydantic import BaseModel, Field
from datetime import datetime


class BaseSchema(BaseModel):
    class Config:
        allow_population_by_field_name = True
        alias_generator = lambda x: ''.join(word.capitalize() if i else word for i, word in enumerate(x.split('_')))


class SysUserPostBase(BaseSchema):

    user_id: Optional[int] = Field("", alias="userId")

    post_id: Optional[int] = Field("", alias="postId")

    create_by: Optional[str] = Field(None, alias="createBy")

    create_time: Optional[datetime] = Field(None, alias="createTime")

    update_by: Optional[str] = Field(None, alias="updateBy")

    update_time: Optional[datetime] = Field(None, alias="updateTime")

    status: Optional[str] = Field(None, alias="status")



class SysUserPostCreate(SysUserPostBase):
    pass


class SysUserPostUpdate(SysUserPostBase):
    pass


class SysUserPostDelete(BaseModel):
    ids: List[int] = Field(..., description="用户与岗位关联表ID列表")


class PageParams(BaseSchema):
    page_num: int = Field(1, ge=1, alias="pageNum", description="页码")
    page_size: int = Field(10, ge=1, le=100, alias="pageSize", description="每页数量")

    create_by: Optional[str] = Field(None, alias="createBy")

    update_by: Optional[str] = Field(None, alias="updateBy")

    status: Optional[str] = Field(None, alias="status")
